﻿<?php 
	session_start();
	include "connect.php"; 
	
	if (!isset($_SESSION["taikhoan"]))
	{
		header("Location: gv-dangnhap.php");
	}
 ?>
<?php
	include("pChart/pData.class");
	include("pChart/pChart.class");
	function createChar($dt1,$dt2,$dt3,$dt4,$mamon)
	{
		// Dataset definition 
		 $DataSet = new pData;
		 $DataSet->AddPoint($dt1,"Serie1");
		 $DataSet->AddPoint($dt2,"Serie2");
		 $DataSet->AddPoint($dt3,"Serie3");
		 $DataSet->AddPoint($dt4,"Serie4");
		 $DataSet->AddAllSeries();
		 $DataSet->SetAbsciseLabelSerie();
		 $DataSet->SetSerieName("Khong hai long","Serie1");
		 $DataSet->SetSerieName("Hai long","Serie2");
		 $DataSet->SetSerieName("Rat hai long","Serie3");
		 $DataSet->SetSerieName("Xuat sac","Serie4");
		
		 // Initialise the graph
		 $Test = new pChart(850,300);
		 $Test->setFontProperties("Fonts/times_1.ttf",8);
		 $Test->setGraphArea(50,30,680,250);
		 $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
		 $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);
		 $Test->drawGraphArea(255,255,255,TRUE);
		 $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2,TRUE);
		 $Test->drawGrid(4,TRUE,230,230,230,50);
		
		 // Draw the 0 line
		 $Test->setFontProperties("Fonts/times_1.ttf",6);
		 $Test->drawTreshold(0,143,55,72,TRUE,TRUE);
		
		 // Draw the bar graph
		 $Test->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),TRUE,80);
		
		
		 // Finish the graph
		 $Test->setFontProperties("Fonts/times_1.ttf",13);
		 $Test->drawLegend(700,200,$DataSet->GetDataDescription(),255,255,255);
		 $Test->setFontProperties("Fonts/times_1.ttf",10);
		 $Test->drawTitle(50,22,$mamon,50,50,50,585);
		 $Test->Render("bieudo/image/".$mamon.".png");
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Kết Quả Đánh Giá</title>
<style type="text/css">

a	{
		color: #006600;
		text-decoration: none;
	}

a:hover { COLOR: #CC0000}

.style2 {
	font-size: 18px;
	font-weight: bold;
	color: #FFFFFF;
}
.style3 {font-size: 14px; font-weight: bold; color: #FFFFFF; }
.style4 {
	color: #000099;
	font-weight: bold;
	font-size:20px;
}
.style5 {	color: #FFFFFF;
	font-weight: bold;
	font-size: 30px;
}
.bg {	border-right-color:#0066FF;
		border-bottom-color:#0066FF;
	}

.bg1 {	border-bottom-color:#0066FF;}

.bg2 {	border-top-color:#0066FF;}

.bg3 {	border-left-color:#0066FF;}

.bg4 {	border-right-color:#0066FF;}
.mo	{	color:#0000FF;	}
.style6 {
	font-size: 22px;
	font-weight: bold;
	color: #000099;
}
.style7{
	font-size: 20px;
	font-weight: bold;
}
</style>
</head>

<body>

<?php
      $magv=$_SESSION['gv'];
      $ma_hp=$_REQUEST["ma"];
	  $hknk=$_REQUEST["hk"];
	  $stt=$_REQUEST["nhom"];
	  $tam=mysql_query("select * from `hocki nienkhoa` where ma_hknk='$hknk' ");
	  $t=mysql_fetch_row($tam);
	  $hk=$t[1];$nk=$t[2];
	  $sql = mysql_query("Select a.ma_gv,a.ten_gv, a.namsinh_gv, a.gioitinh_gv, c.ten_khoa,d.ten_bm FROM `giang vien` a,  `khoa` c, `bo mon` d where a.ma_gv='$magv' and  a.ma_bm=d.ma_bm and d.ma_khoa=c.ma_khoa") ;		
		while($rows = mysql_fetch_array($sql))
		{
			$msgv=$rows["0"];
			$ten=$rows["1"];
			$namsinh=$rows["2"];
			$gioitinh=$rows["3"];
			$khoa=$rows["4"];
			$bomon=$rows["5"];
			
	    }
		$tam=mysql_query("select ten_hp from `hoc phan` where ma_hp='$ma_hp' ");
	    $t=mysql_fetch_row($tam);
	    $tenhp=$t[0];
		$s=mysql_query("select sisolop_hp from `lop hoc phan` where ma_hp='$ma_hp' and ma_hknk='$hknk' and stt_nhom='$stt'");
		$s1=mysql_fetch_row($s);
		$ss=$s1[0];
		$dem=0;
		$k=mysql_query("select distinct (ma_sv) from `danh gia` where ma_hp='$ma_hp' and stt_nhom='$stt' and ma_hknk='$hknk'");
		if (mysql_num_rows($k)==0) $dem=1;
		else
		{
			while($k1=mysql_fetch_row($k))
			{
				   $ma=$k1[0];
				   $dem++;
			}
		}
?>
<table width="900" height="560" align="center" cellpadding="3" cellspacing="3" bordercolor="#CCCCCC" style="border:1px solid #CCCCCC">

<!-- đầu trang --> 	
	<tr> <td width="900" height="70" background="image/header.gif">
    	
        <table width="100%" height="100%" border="0"> 
          <tr>
       		
          <td width="10%" rowspan="2"><img src="image/logo.gif" width="100%" height="70" /></td>
            
            <td width="60%" rowspan="2" height="70" align="center" style="font-size:24px"><div align="center">
              <blockquote>
                <p><span class="style5">Website ĐÁNH GIÁ HỌC PHẦN</span></p>
              </blockquote>
          </div></td>
   		  	
          <td width="30%" valign="bottom"> <table>
       		  <tr><td valign="bottom">
           	  <div align="center" class="style3">
              	<a class="style3" href="trangchu.php">Hướng dẫn</a> | <a class="style3" href="gv-trangchu.php">Trang chủ</a> | <a class="style3" href="logout.php">Thoát</a></div></td></tr>
       	  	  <tr><td valign="bottom">
           	  <div align="center" class="style3">Xin chào, <?php echo $ten; ?> - <?php echo $msgv; ?></div></td></tr> 
   	  	  </table> </td>
        
        </tr> </table>
    
    </td> </tr>

	<tr> <td height="20" width="100%" bordercolor="#FFFFFF"></td> </tr>
	<tr bordercolor="#FFFFFF"> 
           		<td align="center"  height="150" class="bg1">
                	<span class="style6" style="font-size:30px">
					KẾT QUẢ NHẬN XÉT MÔN HỌC <br />
					Học Phần: <?php echo $tenhp; ?><br />
					<input type="hidden" name="ma" value="<?php echo $ma_hp ?>" />
					
					<input type="hidden" name="stt" value="<?php echo $stt ?>" />
					<input type="hidden" name="hk" value="<?php echo $hknk; ?>;" />
					Lớp Học Phần: <?php echo $ma_hp; echo $hknk;echo $stt; ?><br />
					Sỉ Số Lớp Học Phần: <?php echo $ss; ?>
					
					</span></td>
          	</tr>
<!--than trang -->	
	<form id="f" name="f" method="post" action="sv-themdanhgia.php">	
    <tr> <td valign="top" bordercolor="#FFFFFF">
    	
        <table width="900" align="center" cellspacing="0" border="1" bordercolor="#0066FF" cellpadding="0" >
       		
      		
                            
      		<tr align="center" bordercolor="#FFFFFF" bgcolor="#CCCCCC">
            	<td width="413" height="40" ><span class="style7">Nội Dung Đánh Giá</span>				</td>
       	  	  	<td width="133" >
				          <span class="style7">Chưa Hài Lòng</span>				</td>
				<td width="112" >
				          <span class="style7">Hài Lòng</span>				</td>
				<td width="118" >
				          <span class="style7">Rất Hài Lòng</span>				</td>
				<td width="112" >
				          <span class="style7">Xuất Sắc</span>				</td>
				
       	  	</tr>

		   <?php
		           
					
					    $sql=mysql_query("select a.ma_tc,a.noidung_tc from `tieu chi` a, `tieuchi hocki` b where a.ma_tc=b.ma_tc and b.ma_hknk='$hknk' ");
						$khl=array();
						$hl=array();
						$rhl=array();
						$xs=array();
						
						while($row=mysql_fetch_row($sql))
						{
						   $matc=$row[0];
						   $noidung=$row[1];
						   $sql1=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  stt_nhom='$stt' and ma_hp='$ma_hp' and ma_hknk='$hknk' and ma_tc='$matc' and `muc danh gia`='1' group by `muc danh gia`,ma_tc");
						   $sql2=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  stt_nhom='$stt' and ma_hp='$ma_hp' and ma_hknk='$hknk' and ma_tc='$matc' and `muc danh gia`='2' group by `muc danh gia`,ma_tc");
						   $sql3=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  stt_nhom='$stt' and ma_hp='$ma_hp' and ma_hknk='$hknk' and ma_tc='$matc' and `muc danh gia`='3' group by `muc danh gia`,ma_tc");
						   $sql4=mysql_query("select ma_tc,`muc danh gia`,count(*) from `danh gia` where  stt_nhom='$stt' and ma_hp='$ma_hp' and ma_hknk='$hknk' and ma_tc='$matc' and `muc danh gia`='4' group by `muc danh gia`,ma_tc");
						   if(mysql_num_rows($sql1)==0) $muc1=0;
						   else
						   {
						   $r1=mysql_fetch_row($sql1);
						   $muc1=$r1[2];
						   }
						   if(mysql_num_rows($sql2)==0) $muc2=0;
						   else
						   {
						   $r2=mysql_fetch_row($sql2);
						   $muc2=$r2[2];
						   }
						   if(mysql_num_rows($sql3)==0) $muc3=0;
						   else
						   {
						   $r3=mysql_fetch_row($sql3);
						   $muc3=$r3[2];
						   }
						   if(mysql_num_rows($sql4)==0) $muc4=0;
						   else
						   {
						   $r4=mysql_fetch_row($sql4);
						   $muc4=$r4[2];
						   }
						   ?>
						   <tr bordercolor="#FFFFFF">
						       <td  height="60" style="font-size:20px;">
							         <?php echo "&nbsp;&nbsp; $matc. $noidung"; ?> 
							   </td>
					
							   <td  align="center">
							        <?php
									      $t=($muc1/$dem)*100;
										  $t1=round($t,2);
										  $khl[]=$t1; 
										  echo " $t1 &nbsp;&nbsp; %";
										  
									?>
							   </td>
							   <td  align="center">
							        <?php
									       
										  $t=($muc2/$dem)*100;
										  $t1=round($t,2);
										  $hl[]=$t1; 
										  echo " $t1 &nbsp;&nbsp; %";
									?>
							   </td>
							   <td  align="center">
							         <?php
									      
										   $t=($muc3/$dem)*100;
										  $t1=round($t,2); 
										  $rhl[]=$t1;
										  echo " $t1 &nbsp;&nbsp; %";
									 ?>
							   </td>
							   <td  align="center">
							          <?php
									       $t=($muc4/$dem)*100;
										  $t1=round($t,2);
										  $xs[]=$t1; 
										  echo " $t1 &nbsp;&nbsp; %";
										   
									?>
							   </td> 
							     
                           </tr>
						   <?php
						      
						}//while
						 
					 
		   ?>
		  <tr >
		         <td colspan="5" >
				     <table width="100%">
				        
								 <tr><td height="20">&nbsp;</td></tr>
								
								 <tr>
									 <td  style="font-size:22px; font-weight:bold; color:#000099;">
									 * Ý Kiến Khác:
									 </td>
									 
								 </tr>
								 <tr>
									  <td style="font-size:20px; font-weight:bold">
										  <?php
											  $t=mysql_query("select ghi_chu from hoc where stt_nhom='$stt' and ma_hknk='$hknk' and ma_hp='$ma_hp'"); 
											   while ($t1=mysql_fetch_row($t))
											  {	  $t2=$t1[0];
												  if($t2=="") echo "";
												  else
													  echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $t2<br/>";
											  }
										  ?>
									  </td>
									  
								 </tr>
								 
								 <tr><td height="20">&nbsp;</td></tr>
								 <tr>
										 <td width="98%" style="font-size:22px; font-weight:bold; color:#000099;"><label><div align="left" >
										 * Biểu Đồ:
											 </div></label></td>
								</tr>
								
								<tr>
										<td  style="font-weight:bold">
												  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(%)
										</td>
										
						        </tr> 	 
								
								<tr>
										 <td  align="center" >
											<!-- bieu do -->
											
											<?php
											
												createChar($khl,$hl,$rhl,$xs,$ma_hp.$hknk.$stt);
												?>
											<img src="bieudo/image/<?php echo $ma_hp.$hknk.$stt.".png"; ?>" />
											<!-- /bieu do -->
										</td>
		                      </tr>
							  <tr>
													
													<td style="font-weight:bold; font-size:16px" align="right" >
													 Tiêu Chí&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
													</td>
						                   </tr> 
							  
							  <tr > <td height="50"  >
										<table width="100%"> <tr >
											<td width="98%" ><label><div align="right" class="style4">
														 Số Lượng Sinh Viên Tham Gia Đánh Giá: <?php echo $dem; ?>
															 </div></label></td>
											<td width="2%" > </td>
										</tr> </table>
										</td> 
	                         </tr>
					
								 
					</table>
				 </td>
		  </tr>
		 
		 
		  
		  
		   
	    </table>
		  </td>
	  </tr>
    
</form>
	
<!--cuoi trang -->	
	<tr> <td height="5" width="100%" bordercolor="#FFFFFF"></td> </tr>

	<tr> <td height="28" background="image/footer.gif">
    	<table width="100%"> <tr >
    	
    	</tr> </table>
    </td> </tr>
</table>
</body>
</html>
